/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.ipleiria.plp.threads;

import java.io.IOException;
import java.util.Enumeration;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import pt.ipleiria.plp.ui.PhotoBrowser;

/**
 *
 * @author filipe
 */
public class GetFilesInPhotoDir extends Thread {

    PhotoBrowser pb;

    public GetFilesInPhotoDir(PhotoBrowser pb) {
        this.pb = pb;

    }

    public void run() {

        Enumeration files = null;
        String path=null;
        try {
            path = System.getProperty("fileconn.dir.photos");

            FileConnection fconn = (FileConnection) Connector.open(path);

            files = fconn.list("*.*", false);

            if (!fconn.exists()) {
                System.out.println("BUG!");
            }
            fconn.close();

        } catch (IOException ioe) {
            pb.returnFilesInDir(files, path);
        }
        pb.returnFilesInDir(files, path);

    }
}
